package cn.quevo.beetl;

import java.util.Map;

import org.beetl.core.Template;

/**
 * <p>beetl配置类<br/>
 * 组建、方法、函数、扩展注册</p>
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018-03-09 16:35:04
 * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
 * @return
 */
public class BeetlGroupUtilConfiguration extends org.beetl.ext.spring.BeetlGroupUtilConfiguration {
    private BeetlRegister beetlRegister;

    public void setBeetlRegister(BeetlRegister beetlRegister) {
        this.beetlRegister = beetlRegister;
    }

    @Override
    protected void initOther() {
        super.initOther();
        if (beetlRegister != null) {
            beetlRegister.register(groupTemplate);
        }
    }

    /**
     * 获取模板内容
     *
     * @param key
     * @param params
     * @return
     * @author July july_sky@foxmail.com
     * @date 2018-03-09 16:35:14
     * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
     * @version 1.0
     */
    public String getTemplateContent(String key, Map<String, Object> params) {
        Template template = super.getGroupTemplate().getTemplate(key);
        template.binding(params);
        return template.render();
    }
}
